<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增客户管理')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <script type="text/javascript" th:src="@{/pdata/pdata.js}"></script>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-client-add" th:object="${workClient}">
            <input type="hidden" id="clientType" name="clientType" th:field="*{clientType}">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系人：</label>
                <div class="col-sm-8">
                    <input name="clientName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">电话：</label>
                <div class="col-sm-8">
                    <input name="mobile" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">QQ号码：</label>
                <div class="col-sm-8">
                    <input name="QQ" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">微信：</label>
                <div class="col-sm-8">
                    <input name="wechat" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">微博：</label>
                <div class="col-sm-8">
                    <input name="weibo" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收款人：</label>
                <div class="col-sm-8">
                    <input name="payee" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">银行：</label>
                <div class="col-sm-8">
                    <!--<input name="bankName" class="form-control" type="text">-->
                    <select name="bankName" class="form-control m-b" th:with="type=${@dict.getType('work_bank')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开户行：</label>
                <div class="col-sm-8">
                    <input name="bankDeposit" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">银行账号：</label>
                <div class="col-sm-8">
                    <input name="bankAccount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">省份：</label>
                <div class="col-sm-8">
                    <select name="province" id="province" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地市：</label>
                <div class="col-sm-8">
                    <select name="city" id="city" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "work/client"
        var path = window.location.pathname;
        $("#form-client-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-client-add').serialize());
            }
        }
        $(function () {
            var html = "<option value=''>== 请选择 ==</option>";
            $("#city").append(html);

            $.each(pdata, function (idx, item) {
                if (parseInt(item.level) == 0) {
                    html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
                }
            });
            $("#province").append(html);

            $("#province").change(function () {
                if ($(this).val() == "") return;
                $("#city option").remove();

                var code = $(this).find("option:selected").attr("exid");
                code = code.substring(0, 2);
                var html = "<option value=''>== 请选择 ==</option>";

                $.each(pdata, function (idx, item) {
                    if (parseInt(item.level) == 1 && code == item.code.substring(0, 2)) {
                        html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
                    }
                });
                $("#city").append(html);
            });
        });
    </script>
</body>
</html>